Skip to content

WIP: Figure.colorbar: Add alias "no_font_scaling" for "-H" - #4783

Open
yvonnefroehlich wants to merge 3 commits into
mainfrom
add-alias-H-colorbar
Open

WIP: Figure.colorbar: Add alias "no_font_scaling" for "-H"#4783
yvonnefroehlich wants to merge 3 commits into
mainfrom
add-alias-H-colorbar

Conversation

@yvonnefroehlich

@yvonnefroehlich yvonnefroehlich commented Jul 30, 2026

Copy link
Copy Markdown
Member

Description of proposed changes

This PR aims to add an alias for the newly added -H flag of colorbar of GMT 6.7.0. Currently it's no_font_scaling. Feel free to make suggestion for a suitable alias.

TODO

  • Find alias name: no_font_scaling default False
  • Add alias
  • Update note

Related: #4243

Preview: https://pygmt-dev--4783.org.readthedocs.build/en/4783/api/generated/pygmt.Figure.colorbar.html

Example

import pygmt

size = 5
args_bmap = {
    "region": [-size, size] * 2,
    "projection": f"X{size * 2}c",
    "frame": True,
}
args_cb = {
    "cmap": "batlow",
    "position": "jMC+h+w1c",
    "frame": "x+ltitle for a very short cb",
}


fig = pygmt.Figure()

fig.basemap(**args_bmap)
fig.colorbar(**args_cb)

fig.shift_origin(xshift=f"+{size*2+1}c")

fig.basemap(**args_bmap)
fig.colorbar(no_font_scaling=True, **args_cb)   # H = True

fig.show()

Guidelines

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash command is:

  • /format: automatically format and lint the code

@yvonnefroehlich yvonnefroehlich added this to the 0.20.0 milestone Jul 30, 2026
@yvonnefroehlich yvonnefroehlich self-assigned this Jul 30, 2026
@yvonnefroehlich yvonnefroehlich added enhancement Improving an existing feature feature Brand new feature labels Jul 30, 2026
@seisman

seisman commented Jul 30, 2026

Copy link
Copy Markdown
Member

maybe font_scaling with default
to True

@yvonnefroehlich

Copy link
Copy Markdown
Member Author

maybe font_scaling with default to True

Hmmm. Seems we will have fun with double negatives here 😅. My understanding and thoughts so far are:
In GMT, not using -H means the auto-scaling applies. Setting -H turns off the auto-scaling. Setting a flag in GMT without any argument translates in PyGMT to True. So H=True leads to "no auto-scaling is applied". Based on this, the alias for H should contain the "no", with the default False as then no no auto-scaling (i.e., auto-scaling) is applied 😆.

@seisman

seisman commented Jul 31, 2026

Copy link
Copy Markdown
Member

we can use not font_scaling internally

@seisman

seisman commented Aug 10, 2026

Copy link
Copy Markdown
Member

maybe font_scaling with default to True

Hmmm. Seems we will have fun with double negatives here 😅. My understanding and thoughts so far are: In GMT, not using -H means the auto-scaling applies. Setting -H turns off the auto-scaling. Setting a flag in GMT without any argument translates in PyGMT to True. So H=True leads to "no auto-scaling is applied". Based on this, the alias for H should contain the "no", with the default False as then no no auto-scaling (i.e., auto-scaling) is applied 😆.

After thinking it twice, I agree that font_scaling=True as the default is confusing. So let's use no_font_scaling.

Comment thread pygmt/src/colorbar.py
Comment on lines +470 to +473
no_font_scaling
For GMT >=6.5.0, the fontsizes used for the colorbar are scaled automaticly
based on the length of the colorbar. For GMT >= 6.7.0, use this parameter to
turn of the this automatic fontsize scaling.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since PyGMT requires GMT>=6.5.0, I feel we don't need to mention "GMT>=6.5.0" here.

Suggested change
no_font_scaling
For GMT >=6.5.0, the fontsizes used for the colorbar are scaled automaticly
based on the length of the colorbar. For GMT >= 6.7.0, use this parameter to
turn of the this automatic fontsize scaling.
no_font_scaling
By default, the font sizes used for the colorbar are scaled automatically
based on the length of the colorbar. Set this parameter to ``True`` to
turn off the automatic scaling [Requires GMT>=6.7.0].

Comment thread pygmt/src/colorbar.py
turn of the this automatic fontsize scaling.
$projection
$region
$verbose

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The -H option only exists in GMT>=6.7.0, so need to check the current GMT version, and raise an exception if GMT 6.5/6.6 is used and no_font_scaling=True.

Comment thread pygmt/src/colorbar.py
Comment on lines 298 to 299
For GMT >=6.5.0, the fontsizes of the colorbar x-label, x-annotations,
and y-label are scaled based on the width of the colorbar following

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For GMT >=6.5.0, the fontsizes of the colorbar x-label, x-annotations,
and y-label are scaled based on the width of the colorbar following
By default, the fontsizes of the colorbar annotations, label, and unit
are scaled based on the width of the colorbar following

Comment thread pygmt/src/colorbar.py
parameters. To only affect fontsizes related to the colorbar, the
defaults can be changed locally only using ``with pygmt.config(...):``.
:gmt-term:`FONT`)
For GMT >=6.7.0, users should use ``no_font_scaling = True`` to turn of

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For GMT >=6.7.0, users should use ``no_font_scaling = True`` to turn of
For GMT >=6.7.0, users should use ``no_font_scaling = True`` to turn off

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improving an existing feature feature Brand new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants